import { createStore } from 'vuex'

const state = {
  isLogin: false, //是否已经登陆标志，默认为没登陆
  bgColor: 'DarkTurquoise',
  title: '默认值',
  value: '',
  flag: 0,
  //==========保存用户登陆信息==================//
  userName: '',
  userId: '',
  password: '',
  phone: '',
  realname: '',
  email: '',
  sex: '',
  address: '',
  idCard: '',
  age: '',
  type: '',
  photo: '',

  //==========保存用户登陆信息==================//
}
const mutations = {
  //==========保存用户登陆信息==================//
  saveIsLogin(state, isLogin) {
    state.isLogin = isLogin
  },
  saveEmail(state, email) {
    state.email = email
  },
  savePhoto(state, photo) {
    state.photo = photo
  },
  savePhone(state, phone) {
    state.phone = phone
  },
  savePassword(state, password) {
    state.password = password
  },
  saveRealname(state, realname) {
    state.realname = realname
  },
  saveSex(state, sex) {
    state.sex = sex
  },
  saveAddress(state, address) {
    state.address = address
  },
  saveIdCard(state, idCard) {
    state.idCard = idCard
  },
  saveAge(state, age) {
    state.age = age
  },
  saveType(state, type) {
    state.type = type
  },
  saveUsername(state, userName) {
    state.userName = userName
  },
  saveUserId(state, userId) {
    state.userId = userId
  },
  //==========保存用户登陆信息==================//
  change(state, bgcolor) {
    //只能传一个 参数
    state.bgcolor = bgcolor
  },
  changeTitle(state, title) {
    state.title = title
  },
  changeTo(state, flag) {
    state.flag = flag
  },
}
export default createStore({
  state: state,
  // 获取属性的状态
  getters: {},
  mutations: mutations,
  actions: {},
  modules: {},
})
